using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraBars;
using DevExpress.XtraTreeList.Nodes;
using System.Linq;

namespace SqlManager.Forms
{
    public partial class frmMain : DevExpress.XtraBars.Ribbon.RibbonForm
    {
        public frmMain()
        {
            InitializeComponent();
        }

        private void barButtonItem1_ItemClick(object sender, ItemClickEventArgs e)
        {
            Forms.frmGrid grid = new frmGrid();
            Data.DBDataContext db = new SqlManager.Data.DBDataContext();

            grid.MyDataSource = db.all_objects;

            grid.MdiParent = this;
            grid.Show(); 
        }


        public void NodeOlustur()
        {

        }

        private void treeList1_AfterCollapse(object sender, DevExpress.XtraTreeList.NodeEventArgs e)
        {

        }

        private void treeList1_BeforeCollapse(object sender, DevExpress.XtraTreeList.BeforeCollapseEventArgs e)
        {

        }
        Data.DBDataContext db = new SqlManager.Data.DBDataContext();

        private void treeList1_AfterExpand(object sender, DevExpress.XtraTreeList.NodeEventArgs e)
        {

            if (e.Node.GetValue(0) == "View")
            {
                e.Node.Nodes.Clear();
                foreach (var item in db.all_objects.Where(vi => vi.type == "V"))
                {
                    treeList1.AppendNode(new object[] {
            item.name}, e.Node);
                }
            }
            else if (e.Node.GetValue(0) == "Tablolar")
            {
                e.Node.Nodes.Clear();
                foreach (var item in db.all_objects.Where(vi => vi.type == "U"))
                {
                    treeList1.AppendNode(new object[] {
            item.name}, e.Node);
                }
            }
        }

    }
}